<?php if (!defined('THINK_PATH')) exit();?><!-- 广告列表 -->
<table id="advertList" class="easyui-datagrid" title="<?php echo ($currentpos); ?>" data-options="
	fit:true,rownumbers:true,animate:true,fitColumns:true,
	url:'<?php echo U('Pay/bank');?>',idField:'id',border:false,
	toolbar:advertToolbar,pagination:true,singleSelect:true,nowrap:false">
    <thead>
    <tr>
        <th data-options="field:'name',align:'center'">银行</th>
        <th data-options="field:'id',align:'center',formatter:payOperateText">操作</th>
    </tr>
    </thead>
</table>

<!-- 添加 -->
<div id="payAddBox" class="easyui-dialog" title="添加银行"
     data-options="modal:true,closed:true,iconCls:'icon-add',buttons:[{text:'确定',iconCls:'icon-ok',handler:function(){$('#payAddForm').submit();}},{text:'取消',iconCls:'icon-cancel',handler:function(){$('#payAddBox').dialog('close');}}]"
     style="width: 730px; height: 380px;"></div>
<!-- 编辑 -->
<div id="payEditBox" class="easyui-dialog" title="编辑advert"
     data-options="modal:true,closed:true,iconCls:'icon-add',buttons:[{text:'确定',iconCls:'icon-ok',handler:function(){$('#payEditForm').submit();}},{text:'取消',iconCls:'icon-cancel',handler:function(){$('#payEditBox').dialog('close');}}]"
     style="width: 730px; height: 380px;"></div>
<script type="text/javascript">
    //工具栏
    var advertToolbar = [
        { text: '刷新', iconCls: 'icon-reload', handler: payRefreshList },
        { text: '添加', iconCls: 'icon-add', handler: payAdd },
    ];
    function buildFace(val,row,index){
        if(!val){
            return '<div style="height:60px;padding:3px;margin:auto;"></div>';
        }else{
            return '<div style="padding:3px;"><img src="'+val+'" height="60" style="padding:1px;border:1px solid #ccc;"></div>';
        }
    }
    //操作格式化
    function payOperateText(val, row, index){
        var btn = [];
        btn.push('<a href="javascript:void(0);" onclick="bankDelete('+val+')">删除</a>');
        return btn.join(' | ');
    }
    //刷新
    function payRefreshList(){
        $('#advertList').datagrid('reload');
    }
    //添加
    function payAdd(){
        var url = '<?php echo U('Pay/bankAdd');?>';
        $('#payAddBox').dialog({href:url});
        $('#payAddBox').dialog('open');
    }
    //advert编辑
    function bankDelete(id){


        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择', 'error');
            return false;
        }
        $.messager.confirm('提示信息', '确定要删除吗？', function(result){
            if(!result) return false;
            $.post('<?php echo U('Pay/bankDelete');?>', {id: id}, function(data){
                if(!data.status){
                    $.messager.alert('提示信息', data.info, 'error');
                }else{
                    payRefreshList<?php echo ($rand); ?>();
                    $.messager.alert('提示信息', data.info, 'info');
                }
            }, 'json');
        });
    }

</script>